package rma.flp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Transform;

@Service
public class GoogleImageTouchupService implements ImageTouchupService {

	ImagesService imagesService;
	
	@Autowired
	public GoogleImageTouchupService(ImagesService imagesService) {
		this.imagesService = imagesService;
	}
	
	public byte[] touchupImage(byte[] original) {
		Image oldImage = ImagesServiceFactory.makeImage(original);
        Transform resize = ImagesServiceFactory.makeImFeelingLucky();
        Image newImage = imagesService.applyTransform(resize, oldImage);

        return newImage.getImageData();	
	}

}
